import request from '@/utils/request'
import upload from '@/utils/upload'

// 查询运单信息列表
export function getWayBillList(data) {
	return request({
		url: '/logi/sys/waybill/list',
		method: 'post',
		data:data
	})
}

// 修改运单信息
export function updateWayBillProfile(data) {
	return request({
		url: '/logi/sys/waybill',
		method: 'put',
		data: data
	})
}

// 新增运单信息->submitted:0待提交     submitted:1提交
export function addWayBill(data) {
	return request({
		url: '/logi/sys/waybill',
		method: 'post',
		data: data
	})
}

//运单状态操作（提交、取消）
export function updateWayBillStatus(type,waybillId) {
	return request({
		url: '/logi/sys/waybill/'+type+'/'+waybillId,
		method: 'post'
	})
}

//运单新增或修改提货单
export function updateWayBillPickup(data) {
	return request({
		url: '/logi/sys/pickup/save',
		method: 'post',
		data:data
	})
}

//运单状态修改
export function putWayBillStatus(billId,status) {
	return request({
		url: '/logi/sys/waybill/'+billId,
		method: 'put',
		data:{
			status:status,
		}
	})
}

//调度状态修改
export function putScheduleStatus(billId,scheduleStatus) {
	return request({
		url: '/logi/sys/waybill/schedule/'+billId,
		method: 'get',
		data:{
			scheduleStatus:scheduleStatus,
		}
	})
}

//新增调度车次信息
export function addSchedule(data) {
	return request({
		url: '/logi/sys/schedule',
		method: 'post',
		data:data
	})
}


//新增线路
export function addLine(data) {
	return request({
		url: '/logi/sys/line/add',
		method: 'post',
		data:data
	})
}

//运单装车、卸货(type：0装车 1卸车))
export function waybillTruckLoading(data) {
	return request({
		url: '/logi/logi/operation/dispatch/load',
		method: 'post',
		data:data
	})
}

//运单取消装车、取消卸货(type:0 取消装车 1:取消卸货)
export function cancelWaybillTruckLoading(type,loadId) {
	return request({
		url: '/logi/logi/operation/dispatch/cancelLoad/'+type+'/'+loadId,
		method: 'post'
	})
}

//运单发车
export function waybillDepart(scheduleNo) {
	return request({
		url: '/logi/logi/operation/dispatch/depart/'+scheduleNo,
		method: 'post'
	})
}

//运单取消发车
export function cancelWaybillDepart(scheduleNo) {
	return request({
		url: '/logi/logi/operation/dispatch/cancelDepart/'+scheduleNo,
		method: 'post'
	})
}

//运单到达
export function waybillArrive(scheduleNo) {
	return request({
		url: '/logi/logi/operation/dispatch/arrived/'+scheduleNo,
		method: 'post'
	})
}

//运单取消到达
export function cancelWaybillArrive(scheduleNo) {
	return request({
		url: '/logi/logi/operation/dispatch/cancelArrived/'+scheduleNo,
		method: 'post'
	})
}

//运单签收
export function signWaybill(data) {
	return request({
		url: '/logi/sys/sign',
		method: 'post',
		data:data
	})
}

//删除运单签收
export function deleteSignWaybill(signedIds) {
	return request({
		url: '/logi/sys/sign/'+signedIds,
		method: 'delete'
	})
}

//完成运单（运单完成)
export function completeSingleWaybill(billId) {
	return request({
		url: '/logi/sys/waybill/completed/'+billId,
		method: 'get'
	})
}


//完成运单（车次完成)
export function completeWaybill(scheduleNo) {
	return request({
		url: '/logi/logi/operation/dispatch/completed/'+scheduleNo,
		method: 'post'
	})
}

//回单管理-回单操作
export function uploadReceipt(data) {
	return request({
		url: '/logi/logi/operation/dispatch/receipt',
		method: 'post',
		data:data
	})
}

// 删除运单信息
export function deleteWayBill(id) {
	return request({
		url: '/logi/sys/waybill/' + id,
		method: 'delete'
	})
}

// 获取运单信息详细信息
export function getWayBillDetails(id) {
	return request({
		url: '/logi/sys/waybill/'+id,
		method: 'get'
	})
}

// 上传运单相关附件(回单)
export function uploadFile(tempFiles) {
    return upload({
		url: '/sys/oss/upload',
		filePath:tempFiles[0].path,
		file:tempFiles[0].file
    })
}

//查询运单回单跟踪信息列表
export function receiptlogList(data) {
	return request({
		url: '/logi/sys/receiptlog/list',
		method: 'post',
		data:data
	})
}

//查询运单运行日志列表
export function waybilllogList(waybillId) {
	return request({
		url: '/logi/logi/operation/dispatch/waybillLogDetail/'+waybillId,
		method: 'get'
	})
}